package com.hoshiicloud.mallshop.controller.fileupload;

import com.hoshiicloud.common.query.UploadFileResponse;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.mallshop.service.fileupload.StoreFileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author linjx on 2019/9/23
 */
@RestController
@Slf4j
@Api(value = "店铺图片上传",tags = {"店铺图片上传"})
@RequestMapping("/file/store-file-upload")
public class StoreFileUploadController {

    @Autowired
    private StoreFileUploadService storeFileUploadService;

    @ApiOperation(value = "图片上传")
    @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
    public Response<UploadFileResponse> uploadFile(@RequestPart("file") MultipartFile file, @RequestParam("folderName") String folderName) {
        System.out.println("图片文件夹："+folderName);
        UploadFileResponse uploadFileResponse = storeFileUploadService.uploadFile(file, folderName);
        return Response.data(uploadFileResponse);
    }
}
